<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <p></p>
    <script>
        //倒计时结束时间
        const settimes = new Date('2024-08-08T18:49:00').getTime()

        //倒计时函数
        function countdown() {
            const now = new Date().getTime()
            const distance = settimes - now

            //显示倒计时
            document.querySelector('p').innerText = `活动结束剩余时间：${parseInt(distance / 1000)}秒`


            //检查倒计时是否结束
            if (distance < 0) {
                clearInterval(inter)
                document.querySelector('p').innerText = '活动已结束'
            }
        }

        //设置定时器
        const inter = setInterval(countdown, 1000)
    </script>
</body>

</html>